<template>
    <div>
          <div id="company-new">
            <section class="sec-01">
              <div class="back-holder">
                <div class="back-box" @click="goBack">
                  <img src="../../assets/img/wx/mode/back.png"/>
                </div>
              </div>
              <div class="sec-01__title-box" >
                <head-line :txt="sec01Text" :txtStyle="sec01TextStyle"></head-line>
              </div>
              <div class="sec-01__content" >
                <dynamic-item :page="page"></dynamic-item>
              </div>
            </section>
          </div>
    </div>
</template>
<script type="text/ecmascript-6">
  import headLine from "./components/headline"
  import dynamicItem from "./components/dynamic-item"
  import axios from "axios"
  import Core from "core/core"

  export default {
    data() {
      return {
        currentPage: 1,
        pageSize: 10,
        sec01Text: "公司动态",
        sec01TextStyle: {
          "font-size": "20px",
          "color": "#ffffff"

        },
        page:[]
      }
    },
    components: {
      headLine,
      dynamicItem
    },
    methods: {
      goBack() {
        this.$router.back()
      },
      _getArticleList(type){
        let that = this;
        Core.Api.Article.getArticleList(type, this.currentPage, this.pageSize)
          .then(res => {
            let count = res.count;
            let list = res.list;
            list.forEach(v => {
              let time=new Date(v.create_time*1000).toLocaleDateString();
              let obj = {
                article:{
                  title: v.title,
                  timer: time
                },
                img: `http://enjoy-oss.oss-cn-hangzhou.aliyuncs.com/img/${v.img}`,
                id:v.id
              };
              that.page.push(obj);
              that.currentPage+=1;
            })
          })
          .catch(err => {
            console.log(err)
          })
      }
    },
    mounted(){
          this._getArticleList(1);
      // var url="http://47.97.199.202:7910/client/1/article/list?type=1&page=2&limit=10"
      //   axios.get(url).then(
      //    function(res){
      //      let count = res.data.data.count;
      //      let list = res.data.data.list;
      //
      //      console.log(list, 111)
      //      // list.forEach(v => {
      //      //   let obj = {
      //      //     article:{
      //      //       title: v.intro,
      //      //       timer: v.create_time
      //      //     },
      //      //     img: `http://enjoy-oss.oss-cn-hangzhou.aliyuncs.com/img/${v.img}`
      //      //   };
      //      //   that.page.push(obj)
      //      // })
      //    }
      //   ).catch(
      //     function(err){
      //       console.log(err)
      //     }
      //   )
    }
  }
</script>
<style scoped lang="scss">
    #company-new {
      width: 100vw;
      background: #000000;
      min-height: 100vh;
      .sec-01 {
        color: #ffffff;
        position: relative;
        overflow: hidden;
        .back-holder {
          padding: 23px 14px;
          .back-box {
            width: 103px;
            height: 103px;
            padding: 23px 23px;
            img {
              width: 59px;
              height: 59px;
            }
          }

        }
        .sec-01__title-box {
          margin: 10% 0;
        }
        .sec-01__content{
          width: 100vw;
        }
      }
    }
</style>
